<%@page import="org.amj.wn.jamaat.Jamaat.JamaatProperty"%>
<%@page import="org.amj.wn.jamaat.Jamaat"%>
<%@page import="com.google.appengine.api.datastore.Entity"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>New Entry</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
</head>
<body style="width: 90%">

	<jsp:include page="admincommon.jsp"></jsp:include>

	<div class="section">Jamaat List</div>
	<br />
	<%
  		
	  String start = request.getParameter("start");
  		int startIndex = 0;
  		try {
  			startIndex = Integer.parseInt(start);
  		} catch(Exception exp) {}
  		if(startIndex < 0)
  			startIndex = 0;
  
  		int pageSize = 20;
    List<Entity> wns = null;
    
   	wns = Jamaat.search(startIndex, pageSize); 
    
    	
    	
    if (wns.isEmpty()) {
        %>
	<p>No records.</p>
	<%
    } else {
    	%>
    
    
	<div class="datagrid">
    	
	<table>
		<tr>
			<th>Code</th>
			<th>Name</th>
		</tr>
		<%
        for (Entity wn : wns) {
                %>


		<tr>
			<td><a
				href="/admin/jamaateditentry.jsp?wn=<%=wn.getProperty(JamaatProperty.jamaatCode.name()) %>"><%=wn.getProperty(JamaatProperty.jamaatCode.name()) %></a></td>
			<td><%=wn.getProperty(JamaatProperty.name.name()) %></td>

		</tr>

		<%
        }
        
        %>
	</table>
	</div>
	<%
    }
	%>
	<br>
	
	<form method="post" action="listjamaat.jsp">
	<input id="start" type="hidden" name="start"/>
	
	<input value="Previous" type="button" onclick=" document.getElementById('start').value=<%=startIndex - pageSize%>; this.form.submit()" />
	<% if(!wns.isEmpty()) { %>
	<input value="Next" type="button" onclick=" document.getElementById('start').value=<%=startIndex + pageSize%>; this.form.submit()" />
	<%} %>
	</form>
	</body>
</html>
